package com.zmn.mcc.services.interfaces.staff;

import com.zmn.mcc.common.constant.DpermitConsts;
import com.zmn.mcc.model.dto.dpermit.DpermitCountDO;
import com.zmn.mcc.common.dto.permit.DpermitLitDO;
import com.zmn.mcc.model.entity.staff.McStaffDpermit;
import com.zmn.mcc.model.entity.staff.McStaffDpermitQuery;

import java.util.List;

/**
 * @author heguanghua
 * @since 2020/04/14 14:14
 */
public interface StaffDpermitService {

    McStaffDpermit findByKey(Integer staffId, Integer dataType, Integer dataLevel, Integer dataId);
    McStaffDpermit findByKey(McStaffDpermit staffDpermit);

    McStaffDpermit findByQuery(McStaffDpermitQuery query);

    List<McStaffDpermit> listPageByQuery(McStaffDpermitQuery query);

    List<McStaffDpermit> listByStaffId(Integer staffId);
    List<McStaffDpermit> listByStaffIdAndDataType(Integer staffId, Integer dataType);
    List<McStaffDpermit> listByStaffIdAndDataAttr(Integer staffId, Integer dataType, Integer dataLevel);
    List<McStaffDpermit> listByStaffIdAndDataAttr(Integer staffId, Integer dataType, List<Integer> dataLevels);

    List<McStaffDpermit> listByQuery(McStaffDpermitQuery query);

    /**
     * 取得指定员工指定类型的数据权限ID集合
     * @param staffId
     * @param dataType 数据权限类型 {@link DpermitConsts#TYPE_ORGANIZE}
     * @return
     */
    List<Integer> listDataIdByStaffIdAndDataType(Integer staffId, Integer dataType);
    List<Integer> listDataIdByStaffIdAndDataAttr(Integer staffId, Integer dataType, Integer dataLevel);
    List<Integer> listDataIdByStaffIdAndDataAttr(Integer staffId, Integer dataType, List<Integer> dataLevels);
    List<Integer> listDataIdByQuery(McStaffDpermitQuery query);

    /**
     * 取得简化数据权限对象列表
     * @param staffId
     * @param dataType 数据权限类型 {@link DpermitConsts#TYPE_ORGANIZE}
     * @return
     */
    List<DpermitLitDO> listDpermitLitByStaffIdAndDataType(Integer staffId, Integer dataType);
    List<DpermitLitDO> listDpermitLitByQuery(McStaffDpermitQuery query);

    Integer countByQuery(McStaffDpermitQuery query);

    List<DpermitCountDO> countByQueryGroupByParentId(McStaffDpermitQuery query);


    Integer updateByKey(McStaffDpermit staffDpermit);

    Integer updateSubAllByQuery(McStaffDpermitQuery query);


    Integer insert(McStaffDpermit staffDpermit);

    Integer insertByBatch(List<McStaffDpermit> staffDpermits);


    Integer deleteByKey(Integer staffId, Integer dataType, Integer dataLevel, Integer dataId);
    Integer deleteByKey(McStaffDpermit staffDpermit);

    Integer deleteByStaffId(Integer staffId);
    Integer deleteByStaffIdAndDataType(Integer staffId, Integer dataType);
    Integer deleteByStaffIdAndDataAttr(Integer deptId, Integer dataType, List<Integer> dataLevels);
    Integer deleteByQuery(McStaffDpermitQuery query);
}
